<template>
	<view>
		<view class="header">
			<x-status-bar></x-status-bar>
			<view class="flex-center-between header-navbar">
				<x-back-btn></x-back-btn>
				<text class="common-title linecamp-1"></text>
				<view style="width: 24rpx;"></view>
			</view>
		</view>
		<web-view ref="webview" :src="url"></web-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				webview: null,
				url: '',
			}
		},
		onLoad({ url }) {
			this.url = decodeURIComponent(url)
			this.changeWebViewBottom()
		},
		onUnload() {
			this.webview.close()
		},
		methods: {
			// 响应数据
			changeWebViewBottom() {
				// 获取当前屏幕属性
				const sysInfo = uni.getSystemInfoSync()
				const { screenHeight, statusBarHeight, windowBottom } = sysInfo
				const headerHeight = uni.upx2px(98)
				
				setTimeout(() => {
					var currentWebview = this.$scope.$getAppWebview()
					this.webview = currentWebview.children()[0]
					this.webview.setStyle({
						height: (screenHeight - statusBarHeight - headerHeight) + 'px',
						top: (statusBarHeight + headerHeight) + 'px',
						bottom: 'px'
					})
					this.webview.show()
				}, 300)
			}
		}
	}
</script>

<style>

</style>